package com.lazily.homework;


/**
 * @Author: GZQ
 * @date: 2025/4/14 15:52
 * @description: 字符串内存布局
 * @verson: 1.0
 */

public class Homework05 {
	// 程序入口
	public static void main(String[] args) {
		String s1 = "lazily";
		Animal a = new Animal(s1);
		Animal b = new Animal(s1);
		System.out.println(a == b);// F
		System.out.println(a.equals(b));// F
		System.out.println(a.name == b.name); // T

		String s4 = new String("lazily");
		String s5 = "lazily";
		System.out.println(s1 == s4); // F
		System.out.println(s4 == s5);// F

		String t1 = "hello" + s1;
		String t2 = "hellolazily";
		System.out.println(t1.intern() == t2); // T


	}

}

class Animal {
	String name;

	public Animal(String name) {
		this.name = name;
	}
}
